package 代码记录.校招笔试真题.笔试真题_2022.ONES;

import java.util.Scanner;

public class 牛牛的棒棒糖 {
    /**
     * 暴力解法,但是heap溢出
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int[][] arr = new int[n][m];
        while(k > 0){
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            arr[x][y] = 1;
            k--;
        }
        int res = 0;
        for(int i = 0;i < n;i++){
            for(int j = 0;j < m;j++){
                if(arr[i][j] == 1){
                    res = Math.max(res,getMax(arr,i,j));
                }
            }
        }
        System.out.println(res - 1);
    }
    private static int getMax(int[][] arr, int a, int b){
        int res = 0;
        for(int i = 0;i < arr.length;i++){
            if (arr[i][b] == 1) {
                res++;
            }
        }
        for(int j = 0;j < arr[0].length;j++){
            if(arr[a][j] == 1){
                res++;
            }
        }
        return res;
    }
}
